/* client1.c
 *	Simple program to test the network
 *      This is the client 1
 */

#include "syscall.h"


void Print(char* str){
  int c = 0;
  while((str[c] != '\n')){
    c++; 
  }
  c++;
  Write(str,c,ConsoleOutput);
	
}

int main() {
  /*Variable declaration*/
  int lock0, lock1;
  int cond0, cond1;
  int loop;
  int choice;

 

  /***********************/
  /*Start test case 3 ****/
  Print("This is client 1\n");
  Print("***** Start Test 3 ********\n");
  Print("Client1 : CREATE LOCK 0\n");

  lock0 = CreateLock(0); 

  Print("Client1: CREATE CONDITION 0\n");
  cond0 = CreateCondition(0);

  Print("Client1: ACQUIRE LOCK0\n");
  Acquire(lock0);

  Print("Client1: Lock 0 @ index: \n");
  PrintInt(lock0);
  Print(" \n");
  Print("Client1: Cond 0 @ index: \n");
  PrintInt(cond0);
  Print(" \n");
    

  Print("Client 1: WAIT LOCK 0 CONDITION 0\n");
  Wait(lock0,cond0);
  Release(lock0);

  Print("Client1: GOT SIGNAL*******\n");

  lock1 = CreateLock(1);

  Print("Client1: ACQUIRE LOCK1\n");
  Acquire(lock1);
  
  Print("Client1: CREATE CONDITION 1\n");
  cond1 = CreateCondition(1);

  Print("Client1: Lock 1 @ index: \n");
  PrintInt(lock1);
  Print(" \n");
  Print("Client1: Cond 1 @ index: \n");
  PrintInt(cond1);
  Print(" \n");
  

  Print("Client 1: WAIT LOCK 1 CONDITION 1\n");
  Wait(lock1,cond1);
  Release(lock1);   

  Print("Client1: GOT SIGNAL*******\n");
 
  Exit(0);
}
